import ActionGroup from "./ActionGroup.vue"
import moment from "moment";
/**
 * tooltip {boolean}  
 */
const columns = (showOperate) => {
  let arr = [
    // {
    //   type: 'selection',
    //   width: 55
    // },
    {
      label: 'Package ID',
      prop: 'packageId',
      tooltip: false,
    },
    {
      label: 'Name',
      prop: 'name',
      tooltip: false,
    },
    {
      label: 'Version',
      prop: 'version',
      width: 160,
      tooltip: false,
    },
    {
      label: 'File Name',
      prop: 'fileName',
      tooltip: false,
    },
    {
      label: 'Type',
      prop: 'type',
      tooltip: false,
      width: 120,
      formatter: (row, column, cellValue, index) => {
        let type_opction = [
          {label: 'Software', value: 1},
          {label: 'Algorithm', value: 2},
        ];
        return type_opction.find(i => i.value == row.type)?.label || '';
      }
    },
    {
      label: 'Upload Time',
      prop: 'uploadTime',
      tooltip: false,
      width: 160,
      formatter: (row, column, cellValue, index) => {
        return row.uploadTime ? moment(row.uploadTime).format('yyyy-MM-DD HH:mm:ss') : '';
      }
    },
  ]
  if (showOperate) {
    arr.push({
      label: "Operate",
      width: 440,
      render: ActionGroup
    })
  }
  return arr;
};
export default columns;